class Solution2 {
    public String addStrings(String num1, String num2) {
        int i = num1.length()-1;
        int j = num2.length()-1;
        int add = 0;
        StringBuffer strb = new StringBuffer();
        while(i >= 0 || j >= 0 || add != 0){
            int x = 0;
            int y = 0;
            if(i >= 0){
                //要把字符型转换成整形需要减去字符0
                x = num1.charAt(i) - '0';
            }
            if(j >= 0){
                y = num2.charAt(j) - '0';
            }
            int ret = x+y+add;
            strb.append(ret % 10);
            add = ret / 10;
            i--;
            j--;
        }
        strb.reverse();
        return strb.toString();
    }
}
